from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(600,450)
        self.move(300,300)

class btn4green(QPushButton):
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.lb=None;
        self.resize(300,48)
        self.setText('按钮控件')
        self.move(50,30)
        self.setStyleSheet("""
        background-color:green;
        font-size:24px;
        """)
    # def event(self,evt):
    #     print('所有的事件都会触发')
    #     return super().event(evt)

    def mousePressEvent(self, evt):
        print('鼠标按下事件')
        self.lb.setText('华大欢迎你！')
        print(self.lb)
        return super().mousePressEvent(evt)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w1 = Window()
    btn1 = btn4green(w1)

    lb = QLabel(w1)
    lb.setText('点击按钮，会有惊喜')
    print(lb)
    btn1.lb=lb;

    def myslot():
        lb.setText('华大欢迎你！')
        print('myslot事件机制')

    btn1.pressed.connect(myslot)

    w1.show()
    sys.exit(app.exec_())


